package com.itheima.api;

import com.itheima.utils.IdWorker;
import com.itheima.vo.Peachblossom;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;

@DubboService
public class PeachblossomApimpl implements PeachblossomApi{

    @Autowired
    private MongoTemplate mongoTemplate;

    @Autowired
    private IdWorker idWorker;

    //添加语音
    @Override
    public String save(Peachblossom peachblossom) {
        //1、设置属性
        peachblossom.setVid(idWorker.getNextId("peachblossom"));
        peachblossom.setCreated(System.currentTimeMillis());
        //2、调用方法保存对象
        mongoTemplate.save(peachblossom);
        //3、返回对象id
        return peachblossom.getId().toHexString();
    }
}
